//
//  UIBarButtonItem.m
//  ArtHouse
//
//  Created by arthoo on 15/5/23.
//  Copyright (c) 2015年 arthouse. All rights reserved.
//

#import "UIBarButtonItem.h"

@implementation UIBarButtonItem (XXX)
+ (UIBarButtonItem *)itemWithIcon:(NSString *)icon highIcon:(NSString *)highIcon target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setBackgroundImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:highIcon] forState:UIControlStateHighlighted];
    button.frame = (CGRect){CGPointZero, button.currentBackgroundImage.size};
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}
+ (UIBarButtonItem *)itemWithIcon:(NSString *)icon highIcon:(NSString *)highIcon target:(id)target action:(SEL)action frame:(CGRect)frame
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = frame;
    [button setBackgroundImage:[UIImage imageNamed:icon] forState:UIControlStateNormal];
    [button setBackgroundImage:[UIImage imageNamed:highIcon] forState:UIControlStateHighlighted];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}
+ (UIBarButtonItem *)itemWithName:(NSString *)name Color:(UIColor *)color target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitleColor:color forState:(UIControlStateNormal)];
    [button setTitle:name forState:(UIControlStateNormal)];
    button.frame = CGRectMake(0, 0, 40, 20);
    button.titleLabel.font = [UIFont fontWithName:@"Arial" size:15];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}


+ (UIBarButtonItem *)itemWithNameNEW:(NSString *)name Color:(UIColor *)color target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitleColor:color forState:(UIControlStateNormal)];
    [button setTitle:name forState:(UIControlStateNormal)];
    button.frame = CGRectMake(0, 0, 50, 20);
    button.titleLabel.font = [UIFont fontWithName:@"Arial" size:15];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return [[UIBarButtonItem alloc] initWithCustomView:button];
}

+ (UIButton *)ButtonWithName:(NSString *)name Color:(UIColor *)color target:(id)target action:(SEL)action
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    [button setTitleColor:color forState:(UIControlStateNormal)];
    [button setTitle:name forState:(UIControlStateNormal)];
    button.frame = CGRectMake(0, 0, 40, 20);
    button.titleLabel.font = [UIFont fontWithName:@"Arial" size:15];
    [button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
    return button;
}


@end
